import request from '@/utils/request'

/**
 * 分页查询商品
 */
export function listSpuByPage(params) {
  return request({
    url: '/service-goods/goods/spu/page',
    method: 'GET',
    params
  })
}

/**
 * 根据spuId查询商品详情
 */
export async function getSpuDetail(spuId) {
  const url = '/service-goods/goods/spu/detail/' + spuId
  return await request.loadData(url)
}

/**
 * 根据spuId查询商品库存集合
 */
export async function listSku(spuId) {
  const url = '/service-goods/goods/sku/list/' + spuId
  return await request.loadData(url)
}

/**
 * 保存/编辑商品
 */
export function saveOrUpdateSpu(data, method) {
  return request({
    url: '/service-goods/goods/spu',
    method,
    data
  })
}

/**
 * 删除商品
 */
export function deleteSpu(id) {
  return request({
    url: '/service-goods/goods/spu/' + id,
    method: 'DELETE'
  })
}
